"""
电信用户流失分析
"""
import numpy as np
import csv

def load_csv():
    data = []
    with open('../day02/CustomerSurvival.csv', 'r') as f:
        print(f)
        #读到每行数据
        for line in f.readlines():
            data.append(tuple(line[:-1].split(',')))

        resData = np.array(data,dtype={'names':['index','pack_type','extra_time','extra_flow','pack_change','contract','asso_pur','group_user','use_month','loss'],
     'formats':['i4','i4','f4','f4','i4','i4','i4','i4','i4','i4']})
        return resData
        # csvReader = csv.reader(f)
        # data = list(csvReader)
        # print(data)
        # 将所有数据，整合成列表套元组
        # 使用array并设置dtype
        # numpyData = np.array(data,dtype={'names':['index','pack_type','extra_time','extra_flow','pack_change','contract','asso_pur','group_user','use_month','loss'],
        # 'formats':[]})

        # pass

    # {'names':['index','pack_type','extra_time','extra_flow','pack_change','contract','asso_pur','group_user','use_month','loss'],
    #  'formats':[]}
data = load_csv()
print(data['index'])
# print(load_csv())